package com.spl.seriallibrary.locker.rocktech;


import com.spl.seriallibrary.locker.ICMD;
import com.spl.seriallibrary.util.SerialPortTools;

public class RocktechCMD implements ICMD {

    @Override
    public byte[] openLock(String str) {
        byte[] lockOrder = new byte[7];
        lockOrder[0] = (byte) 0xAA;
        lockOrder[1] = 0x55;
        lockOrder[2] = 0x03;
        lockOrder[3] = SerialPortTools.calculateBoard(str);
        lockOrder[4] = 0x50;
        lockOrder[5] = (byte) (SerialPortTools.calculateLock(str) - 1);
        lockOrder[6] = SerialPortTools.calcCrc8(lockOrder, 0, 6);
        return lockOrder;
    }

    @Override
    public byte[] queryLock(String str) {
        byte[] lockOrder = new byte[6];
        lockOrder[0] = (byte) 0xAA;
        lockOrder[1] = 0x55;
        lockOrder[2] = 0x02;
        lockOrder[3] = SerialPortTools.calculateBoard(str);
        lockOrder[4] = 0x51;
        lockOrder[5] = SerialPortTools.calcCrc8(lockOrder, 0, 5);
        return lockOrder;
    }

}
